package nuc.soft.xsf.controller;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import net.sf.json.JSONObject;
import nuc.soft.xsf.model.ProjectTest;
import nuc.soft.xsf.model.Report;
import nuc.soft.xsf.model.Titletype;
import nuc.soft.xsf.model.TitletypeProject;
import nuc.soft.xsf.service.IProjectTestService;
import nuc.soft.xsf.service.IReportService;
import nuc.soft.xsf.service.ITitleTypeProjectService;
import nuc.soft.xsf.service.ITitletypeService;
import nuc.soft.xsf.tools.Tools;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = "/TitleTypeProejctController", produces = "text/html;charset=UTF-8")
public class TitleTypeProjectController {
	@Resource
    private ITitleTypeProjectService titleProjectService;
	
	@Resource
	private ITitletypeService titleTypeService;
	
	@Resource
	private IProjectTestService projectService;
	@RequestMapping(value = "/findByCondition.action", produces = "text/html;charset=UTF-8")
	@ResponseBody
	public String findByCondition(TitletypeProject  titleProejct){
		ProjectTest project =new ProjectTest();
		project.setProjectParentId(titleProejct.getProjectId());
		Map map01=Tools.transBean2Map(project);
		List<ProjectTest> list =projectService.findByCondition(map01);
		titleProejct.setProjectId(list.get(0).getProjectId());
		Map map=Tools.transBean2Map(titleProejct);
		List<TitletypeProject> titleProjectList=titleProjectService.findByCondition(map);
		String str="";
		for(int i=0;i<titleProjectList.size();i++){
			Titletype title=new Titletype();
			title=titleTypeService.findById(titleProjectList.get(i).getTitleTypeid());
			str+=title.getTitleTypename()+" ";
		}
		JSONObject json=new JSONObject();
		json.put("str", str);
		return json.toString();
	}
	
	
	
	
}
